package com.szcinda.call.service;

import com.szcinda.call.repository.OrderDetailAccount;
import com.szcinda.call.repository.OrderDetailAccountRepository;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

@Service
public class OrderDetailAccountServiceImpl implements OrderDetailAccountService {
    private final OrderDetailAccountRepository orderDetailAccountRepository;

    public OrderDetailAccountServiceImpl(OrderDetailAccountRepository orderDetailAccountRepository) {
        this.orderDetailAccountRepository = orderDetailAccountRepository;
    }

    @Override
    public void login(LoginDto loginDto) {
        OrderDetailAccount orderDetailAccount = orderDetailAccountRepository.findByUserName(loginDto.getUserName());
        Assert.isTrue(orderDetailAccount != null, "找不到账号,请检查用户名");
        Assert.isTrue(orderDetailAccount.getPassword().equals(loginDto.getPassword()), "账号密码错误");
    }
}
